package com.internetCafes.spms.web.extend.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.internetCafes.spms.common.base.BaseWebController;
import com.internetCafes.spms.core.utils.R;
import com.internetCafes.spms.web.extend.model.CourseInfo;
import com.internetCafes.spms.web.extend.service.ICourseInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 课程信息表 前端控制器
 * </p>
 *
 * @author jill
 * @since 2020-12-04
 */
@RestController
@RequestMapping("/course/courseInfo")
public class CourseInfoController extends BaseWebController {

    @Autowired
    private ICourseInfoService courseInfoService;

    /**
     * 查询
     * @return
     */
    @RequestMapping(
            value = "paging",
            method = RequestMethod.GET)
    @RequiresPermissions("certificate:certificateInfo:list")
    public R paging(@RequestParam Map<String, Object> params, HttpServletRequest request) {
        Page<CourseInfo> page = new Page<CourseInfo>(1, 20);
        IPage<CourseInfo> rsPage = courseInfoService.page(page);
        return getPageResult(rsPage);
    }

    /**
     * 添加
     * @return
     */
    @RequestMapping(
            value = "add",
            method = RequestMethod.POST)
    public R add(@RequestBody CourseInfo entity) {
        courseInfoService.save(entity);
        return R.ok();
    }


}
